/*
 * @Author: YYJ
 * @Date: 2023-12-16 14:40:39
 * @Description: 
 * @FilePath: \lgd-admin\src\services\study\content\index.tsx
 */
import { request } from '@umijs/max';

export interface StudyContentParams {
  key?: number
  catalogId?: number
  current?: number
  pageSize?: number
}

export interface StudyContentItem {
  key?: number
  id?: number
  catalogId?: number
  catalogName?: string
  type?: string
  name?: string
  author?: string
  translator?: string
  publisher?: string
  resource?: string
  sortNum?: number
  doneIndex?: number
  targetIndex?: number
  currentProgress: number
  startStudyDate?: Date
  lastStudyDate?: Date
  studyDays?: number
  status: string
  optType: 'add' | 'edit'
}

export interface OverviewItem {
  todayDuration?: number
  yesterdayDuration?: number
  todaySub?: number
  todayTrend: 'up' | 'down'
  weekDuration?: number
  lastWeekDuration?: number
  weekSub?: number
  weekTrend: 'up' | 'down'
  monthDuration?: number
  lastMonthDuration?: number
  monthSub?: number
  monthTrend?: 'up' | 'down'
  yearDuration?: number
  lastYearDuration?: number
  yearSub?: number
  yearTrend?: 'up' | 'down'
}

export interface StudyContentReq {
  id?: number
  catalogId?: number
  doneIndex?: number
  targetIndex?: number
  updateIndex?: number
  duration?: number
  remark: string
}

/** 查询学习目录列表 POST /admin/studyContent/queryList */
export async function queryList(body: StudyContentParams) {
  return request<API.LgdTable>('/admin/studyContent/queryList', {
    method: 'POST',
    data: body
  })
}

/** 查询学习目录列表 POST /admin/studyContent/addUpdate */
export async function addUpdate(body: StudyContentItem) {
  return request<API.LgdResult>('/admin/studyContent/addUpdate', {
    method: 'POST',
    data: body
  })
}

/** 查询学习目录列表 POST /admin/studyContent/updateProgress */
export async function updateProgress(body: StudyContentReq) {
  return request<API.LgdResult>('/admin/studyContent/updateProgress', {
    method: 'POST',
    data: body
  })
}

/** 查询学习目录列表 POST /admin/studyContent/updateProgress */
export async function focusProgress(body: StudyContentReq) {
  return request<API.LgdResult>('/admin/studyContent/focusProgress', {
    method: 'POST',
    data: body
  })
}

export async function remove(id?: number) {
  return request('/admin/studyContent/remove?id=' + id, {
    method: 'POST',
  })
}

export async function start(id?: number) {
  return request('/admin/studyContent/start?id=' + id, {
    method: 'POST',
  })
}